'''
Created on 2009-10-16

@author: loudly
'''

SEATS = {0: [0, 1, 2, 3],
         1: [1, 0, 3, 2],
         2: [2, 3, 1, 0],
         3: [3, 2, 0, 1], 
         }

def seatRotate(handNumberAfterRotate, playersBeforeRotate):
    if handNumberAfterRotate % 4 > 0 :
        return playersBeforeRotate
    
    indexAfter = (handNumberAfterRotate / 4) % 4
    indexBefore = (indexAfter + 3) % 4
    seatsAfter = SEATS[indexAfter]
    seatsBefore = SEATS[indexBefore]
    
    playersOrigin = ['', '', '', '']
    
    for i in range(0, 4) :
        playersOrigin[seatsBefore[i]] = playersBeforeRotate[i]
    
    playersRet = ['', '', '', '']
    
    for i in range(0, 4) :
        playersRet[i] = playersOrigin[seatsAfter[i]]
        
    return playersRet